<template>
  <div>
    <wxc-overlay
          :show="announcement.visiabled"
          opacity="0.6"
          @wxcOverlayBodyClicking="wxcOverlayBodyClicking"
          ></wxc-overlay>
    <div class="announcement-wrapper" :class="[announcement.visiabled ? 'show' : 'hide']">
      <div>
        <button class="btn-close iconfont icon-close" @click="handleClose"></button>
      </div>
      <text class="title">{{announcement.title}}</text>
      <text class="content">{{announcement.content}}</text>
    </div>
  </div>
</template>

<style lang="scss" scoped>
  .announcement-wrapper {
    position: fixed;
    top: 15%;
    left: 40px;
    right: 40px;

    &.hide {
      display: none;
    }

    &.show {
      display: block;
    }

    .btn-close {
      background-color: unset;
      width: fit-content;
      margin: 0 auto 30px auto;
      color: #ffffff;
      font-size: 64px;
      outline: none;
    }

    .title {
      background-color: #F45551;
      padding: 40px 0;
      text-align: center;
      color: #FFFFFF;
      border-top-left-radius: 20px;
      border-top-right-radius: 20px;
    }

    .content {
      background-color: #FFFFFF;
      padding: 40px;
      border-bottom-left-radius: 20px;
      border-bottom-right-radius: 20px;
      text-indent: 64px;
      line-height: 64px;
      font-size: 30px;
    }
  }
</style>

<script>
import { WxcOverlay } from 'weex-ui'

export default {
  components: { WxcOverlay },
  data () {
    return {
      visiabled: false,
      title: '',
      content: ''
    }
  },
  props: {
    announcement: {
      type: Object,
      default: function () {
        return {
          visiabled: this.visiabled,
          title: this.title,
          content: this.content
        }
      }
    }
  },
  methods: {
    wxcOverlayBodyClicking () {
      this.handleClose()
    },
    handleClose () {
      this.announcement.visiabled = false
      this.$emit('changeAnnouncementVisiabled', this.announcement.visiabled)
    }
  }
}
</script>
